import { deepClone } from '@/util/util.js';
export const clearRequireds = (option, viewFlag) => {
    if (viewFlag) {
        var viewOption = deepClone(option)
        if (viewOption.column && viewOption.column.length != 0) {
            viewOption.column.map(item => {
                if (item.rules) {
                    if (item.rules.length == 1) {
                        item.rules[0].required = false
                    } else {
                        item.rules.map(items => {
                            if (items.required) {
                                items.required = false
                            }
                        })
                    }
                }
                if (item.children && item.children.length > 0) {
                    item.children.map(child => {
                        if (child.rules && child.rules.length > 0) {
                            if (child.rules.length == 1) {
                                child.rules[0].required = false
                            } else {
                                child.rules.map(chi => {
                                    if (chi.required) {
                                        chi.required = false
                                    }
                                })
                            }
                        }

                    })

                }
            })
        }
        option = viewOption
    } else {
        var editOption = deepClone(option)
        // if (editOption.column && editOption.column.length != 0) {
        //     editOption.column.map(item => {
        //         if (item.rules && item.rules.length > 0) {
        //             if (item.rules.length == 1) {
        //                 item.rules[0].required = true
        //             } else {
        //                 item.rules.map(items => {
        //                     if (items.required == false) {
        //                         items.required = true
        //                     }
        //                 })
        //             }
        //         }
        //         if (item.children && item.children.length > 0) {
        //             item.children.map(child => {
        //                 if (child.rules && child.rules.length > 0) {
        //                     if (child.rules.length == 1) {
        //                         child.rules[0].required = true
        //                     } else {
        //                         child.rules.map(chi => {
        //                             if (!chi.required) {
        //                                 chi.required = true
        //                             }
        //                         })
        //                     }
        //                 }
        //             })
        //         }
        //     })
        // }
        option = editOption
    }

    return option
}

export const culomnSpan = () => {
    let width = window.screen.width
    var culomnSpan=''
    if(width<=1024){
      culomnSpan = 24
    }else if(width>1024&&width<1440){
      culomnSpan = 12
    }else if(width>=1440 && width<1920){
      culomnSpan = 8
    }else{
        culomnSpan = 6
    }
    return culomnSpan
  }